<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>输入显示提示</title>
		<script src="../js/jquery-3.6.0.js" type="text/javascript" charset="utf-8"></script>
	</head>
	
	<body>
		<input type="text" name="" id="search" value="" />
		<ul id="list">
			<li id="div1">nh</li>
			<li>nhhh</li>
			<li>hn</li>
			<li>hnn</li>
		</ul>
		<script type="text/javascript">
			$(document).ready(function(){
				$('#search').on('keyup',function(){//绑定事件
					/* console.log(this.value); */
					/* console.log($(this).val()); */
					$('#list li').css('background','transparent');
					if(this.value != ''){
						$('#list li:contains('+this.value+')').css('background','#f00');
						
					}
					
				});
			});
		</script>
	</body>
</html>
